<?php
class HUsersRoles {
	function getAllRolesExceptAdmin(){
		$sql = "SELECT * FROM portal_roles WHERE id != '1' AND id != '2'";
		$a = HSql::doQuery($sql);
		return HSql::fetch2Array($a);
	}
	
	function insert($roleName){
		try {
			$sql = "INSERT INTO portal_roles (role_name) VALUES ('".$roleName."')";
			$result = HSql::doQuery($sql);
			return $result;
		}catch (Exception $ex){
			throw new $ex->getMessage();
		}
	}
	
	function getOneRoleById($id){
		$sql = "SELECT * FROM portal_roles WHERE id ='".$id."'";
		$a = HSql::fetch2Array(HSql::doQuery($sql));
		return $a;
	}
	
	function update($id, $roleName){
		try {
			$sql = "UPDATE portal_roles SET role_name ='".$roleName."' WHERE id ='".$id."'";
			$result = HSql::doQuery($sql);
			return $result;
		}catch (Exception $ex){
			throw new $ex->getMessage();
		}
	}
	
	function delete($id){
		try {
			$sql = "DELETE FROM portal_roles WHERE id ='".$id."'";
			$result = HSql::doQuery($sql);
			return $result;
		}catch (Exception $ex){
			throw new $ex->getMessage();
		}
	}
}
?>